using System;
using System.Threading;
using System.Collections.Generic;

using stefc.geo.lib;
using stefc.geo.platform;

namespace stefc.geo.xmpp
{	
	public class MyClass
	{
        static void Main(string[] args)
        {   
			const string JID_SENDER     = "stefan.boether@jabber.ccc.de";
			const string JID_RECEIVER   = "stefan.boether@googlemail.com";
			
			const string PASSWORD       = "panda";   // password of the JIS_SENDER account

			var xmpp = new XMPPComp(5);
			
			//xmpp.In_Start();
			
			var thread = new Thread( x => xmpp.In_Start(JID_SENDER,PASSWORD) );
			
			thread.Start();
			
			xmpp.Out_Presence += delegate(KeyValuePair<string, Geographic> obj) {
				Console.WriteLine("{0} {1}", obj.Key, obj.Value);
			};
			
			// gps.Out_GPSFix +=  In_GPSFix;
			
			Console.WriteLine("sending presence");
			xmpp.In_Presence(new Geographic(45.0,10.0));
			
			string message = Console.ReadLine();
			
			xmpp.In_Send(JID_RECEIVER, message);
			
			Console.ReadLine();
			
			
			xmpp.In_Stop();

        }

        static void HandleXmppOnError (object sender, Exception ex)
        {
        	Console.WriteLine(ex.Message);
        }

        static void HandleXmppOnAuthError (object sender,  agsXMPP.Xml.Dom.Element e)
        {
        	Console.WriteLine(e.InnerXml);
        }

		public static void In_GPSFix(Geographic geo)
        {
			Console.WriteLine("Lat={0} Lon={1}", geo.Lat, geo.Lon);
        }  
    }
}

